<template>
  <div class="SongListItem">
    <div class="itemTop">
      <div class="left">
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-yinle"></use>
        </svg>
        <h3>播放全部</h3>
        <span class="all">{{ `(共${songsList.length}首)` }}</span>
      </div>
    </div>
    <div class="showSongs">
      <ul>
        <li v-for="(item,index) in songsList" :key="index" >
          
          <div class="itemLeft" @click="choosePlay(index)">
              <p class="num" :style="{margin:'10px 10px'}">{{index+1}}</p>
              <p class="name">
                  <span>{{item.name}}</span>
                  <span class="personName">
                       <span v-for="(per,index) in item.ar" :key="index">
                          {{per.name}}
                       </span>
                  </span>
                 
              </p>
          </div>
          <div class="itemRight">
            <svg class="icon" aria-hidden="true">
              <use xlink:href="#icon-yinle"></use>
            </svg>
            <svg class="icon" aria-hidden="true">
              <use xlink:href="#icon-icon-test" :style="{fill:'white'}"></use>
            </svg>
          </div>
        </li>
      </ul>
    </div>
    
  </div>
</template> 

<script>
import {mapMutations,mapState} from 'vuex'
export default {
  data(){
      return {
          margin:''
      }
  },
 

  
  computed:{
    ...mapState(['songsList','whichSong'])
  },

  methods:{
    ...mapMutations(['CHANGESONGSLIST','CHOOSEWHICH']),
    choosePlay(index){
      // 改变歌曲
      this.CHANGESONGSLIST(this.songsList) 
      // 改变歌曲索引
      if(index===this.whichSong){
        this.CHOOSEWHICH(String(index))
      }else{
        this.CHOOSEWHICH(index)
      }
    }
  },
  
  
 
};
</script>

<style scoped>
    .SongListItem{
        padding: 10px;
        background: white;
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
    }
    .showSongs ul li{
        display: flex;
        justify-content: space-between;
    }
    .itemLeft{
        display: flex;
        align-items: center;
    }
    .itemLeft .name{
        display: flex;
        flex-direction: column;
    }
    .itemTop .left{
        display: flex;
    }
    .num{
        color: #ccc;
        width:30px;
        text-align: center;
    }
    .name>span:nth-of-type(1){
        font-weight: 600;
        font-size: 18px;
        width: 200px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
    .name>span:nth-of-type(2){
        display: flex;
        font-size: 12px;
        color: rgba(159, 68, 68, 0.918);
        font-weight: 300;
    }
    .all{
        font-size: 16px;
        color: rgba(204, 204, 204);
    }
    .left{
        display: flex;
        align-items: center;
    }
    .personName{
      width: 200px;
      overflow: hidden;
    }
</style>